<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>换车申请</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div tabid="tabA" title="换车信息" lselected="true">
                <div class="fieldset1 tabel_col clearFix">
                    <c:if test="${flowFlag != 'true'}">
                        <div>
                            <br/>
                            <span style="color: red">请线上签署纸质版换车协议并上传至项目资料-租赁物资料-租赁物其他资料。</span>
                        </div>
                        <br/>
                    </c:if>
                    <div class="fieldBox col_33">
                        <div class="label">支付表号</div>
                        <div class="field">
                            <span id="oldPaySchNo" name="oldPaySchNo">${prjPrdPaySchMVO.paySchNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">支付表状态</div>
                        <div class="field">
                            <span id="oldPayerStsCd" name="oldPayerStsCd">${prjPrdStsCd}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">放款金额</div>
                        <div class="field">
                            <span id="oldPayAmt" name="oldPayAmt"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">实际放款金额</div>
                        <div class="field">
                            <span id="oldActPayAmt" name="oldActPayAmt"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">租赁期数</div>
                        <div class="field">
                            <span id="oldLsPd" name="oldLsPd">${prjPrdPaySchMVO.lsPd}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">已还期次</div>
                        <div class="field">
                            <span id="oldPayPd" name="oldPayPd">${payPd}</span>
                        </div>
                    </div>
                </div>
                <div class="fieldset1 tabel_col clearFix">
                    <div class="caption">
                        <span class="title">原资产信息</span>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">租赁物名称</div>
                        <div class="field">
                            <a id="oldPrdNmLink" href="" class="link">
                                <span id="oldPrdNm" name="oldPrdNm"></span>
                            </a>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">租赁物价格</div>
                        <div class="field">
                            <span id="oldGuidePc" name="oldGuidePc"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">马力</div>
                        <div class="field">
                            <span id="oldHp" name="oldHp"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">品牌</div>
                        <div class="field">
                            <span id="oldBrand" name="oldBrand"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">VIN/车架号</div>
                        <div class="field">
                            <span id="oldVIN" name="oldVIN"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">上牌状态</div>
                        <div class="field">
                            <span id="oldSpSts" name="oldSpSts"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">合格证编号</div>
                        <div class="field">
                            <span id="oldCertNo" name="oldCertNo"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">抵押状态</div>
                        <div class="field">
                            <span id="oldDySts" name="oldDySts"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">商业险保单状态</div>
                        <div class="field">
                            <span id="oldCommercialPlcStsCd" name="oldCommercialPlcStsCd"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">交强险保单状态</div>
                        <div class="field">
                            <span id="oldPlcSts" name="oldPlcSts"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">GPS1</div>
                        <div class="field">
                            <span id="oldGPS1" name="oldGPS1"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">GPS2</div>
                        <div class="field">
                            <span id="oldGPS2" name="oldGPS2"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">GPS3</div>
                        <div class="field">
                            <span id="oldGPS3" name="oldGPS3"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">发动机号</div>
                        <div class="field">
                            <span id="oldEngineNo" name="oldEngineNo"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">发动机型号</div>
                        <div class="field">
                            <span id="oldEngMdl" name="oldEngMdl"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">发票状态</div>
                        <div class="field">
                            <span id="oldInvoiceSts" name="oldInvoiceSts"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">厂商</div>
                        <div class="field">
                            <span id="oldMfrNm" name="oldMfrNm"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">挂靠公司</div>
                        <div class="field">
                            <span id="oldCompNm" name="oldCompNm"></span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">供应商</div>
                        <div class="field">
                            <span id="oldSplNm" name="oldSplNm"></span>
                        </div>
                    </div>
                </div>
                <form id="formSet1">
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">新资产信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">租赁物名称</div>
                            <div class="field">
                                <a href="javascript:showPrjPrdDetail(${newDtlVO.prjPrdId})" class="link">
                                    <span id="newPrdNm" name="newPrdNm">${newDtlVO.prdNm}</span>
                                </a>
                                <c:if test="${detailFlag == 'false'}">
                                    &nbsp;&nbsp;
                                    <c:choose>
                                        <c:when test="${newDtlVO.prjPrdId != null}">
                                            <a href="javascript:modifyPrjPrd(${newDtlVO.prjPrdId})" class="link">
                                                <span>修改</span>
                                            </a>
                                            &nbsp;&nbsp;
                                            <c:if test="${flowFlag != 'true'}">
                                                <a href="javascript:removePrjPrd(${newDtlVO.prjPrdId})" class="link">
                                                    <span>移除</span>
                                                </a>
                                            </c:if>
                                        </c:when>
                                        <c:otherwise>
                                            <a href="javascript:addPrjPrd()" class="link">
                                                <span>新增</span>
                                            </a>
                                            &nbsp;&nbsp;
                                            <a href="javascript:addPrjPrdGC()" class="link">
                                                <span>新增挂车</span>
                                            </a>
                                        </c:otherwise>
                                    </c:choose>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">租赁物价格</div>
                            <div class="field">
                                <span id="newGuidePc" name="newGuidePc"></span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">马力</div>
                            <div class="field">
                                <span id="newHp" name="newHp">${newDtlVO.hp}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">品牌</div>
                            <div class="field">
                                <span id="newBrand" name="newBrand">${newDtlVO.brand}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">VIN/车架号</div>
                            <div class="field">
                                <span id="newVIN" name="newVIN">${newDtlVO.vin}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">上牌状态</div>
                            <div class="field">
                                <span id="newSpSts" name="newSpSts">${newDtlVO.licAudStsCdNm}</span>
                                <c:if test="${newDtlVO.isExistSp == '0' && detailFlag == 'false'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:addSp('${newDtlVO.dtlId}','${newDtlVO.certNo}')" class="link">
                                        <span>添加</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.isExistSp == '1' && detailFlag == 'false'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:modifySp(${newDtlVO.dtlId})" class="link">
                                        <span>修改</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.isExistSp == '1'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:showSp(${newDtlVO.dtlId})" class="link">
                                        <span>查看上牌信息</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">合格证编号</div>
                            <div class="field">
                                <a href="javascript:detailPrjPrdVehInfo('${newDtlVO.actPrdId}','${newDtlVO.dtlId}')" class="link">
                                    <span id="newCertNo" name="newCertNo">${newDtlVO.certNo}</span>
                                </a>
                                &nbsp;&nbsp;
                                <c:if test="${newDtlVO.certNo != null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    <a href="javascript:modifyPrjPrdVehInfo('${newDtlVO.actPrdId}','${newDtlVO.dtlId}','')" class="link">
                                        <span>修改</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.certNo != null && (isNeedPrice == '1'||isDetail == '0')}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:modifyPrjPrdVehInfo('${newDtlVO.actPrdId}','${newDtlVO.dtlId}','1')" class="link">
                                        <span>修改GPS</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.dtlId != null && newDtlVO.certNo == null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    <a href="javascript:addPrjPrdVehInfo(${newDtlVO.dtlId})" class="link">
                                        <span>添加</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">抵押状态</div>
                            <div class="field">
                                <span id="newDySts" name="newDySts">${newDtlVO.guarStsCdNm}</span>
                                <c:if test="${newDtlVO.isExistDy == '0' && detailFlag == 'false'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:addDy(${newDtlVO.dtlId})" class="link">
                                        <span>添加</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.isExistDy == '1' && detailFlag == 'false'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:modifyDy(${newDtlVO.dtlId})" class="link">
                                        <span>修改</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.isExistDy == '1'}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:showDy(${newDtlVO.dtlId})" class="link">
                                        <span>查看抵押信息</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">商业险保单状态</div>
                            <div class="field">
                                <span id="newCommercialPlcStsCd" name="newCommercialPlcStsCd">${newDtlVO.commercialPlcStsCdNm}</span>
                                <c:if test="${newDtlVO.commercialPlcId != null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:modifyPlc('${newDtlVO.commercialPlcId}')" class="link">
                                        <span>修改</span>
                                    </a>
                                    &nbsp;&nbsp;
                                    <a href="javascript:deletePlc('${newDtlVO.commercialPlcId}','${newDtlVO.dtlId}')" class="link">
                                        <span>删除</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.dtlId != null && newDtlVO.commercialPlcId == null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:addPlc('${newDtlVO.dtlId}','${newDtlVO.certNo}','1')" class="link">
                                        <span>添加</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.commercialPlcId != null}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:showPlc('${newDtlVO.commercialPlcId}')" class="link">
                                        <span>查看</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">交强险保单状态</div>
                            <div class="field">
                                <span id="newPlcSts" name="newPlcSts">${newDtlVO.plcStsCdNm}</span>
                                <c:if test="${newDtlVO.insPlcId != null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:modifyPlc('${newDtlVO.insPlcId}')" class="link">
                                        <span>修改</span>
                                    </a>
                                    &nbsp;&nbsp;
                                    <a href="javascript:deletePlc('${newDtlVO.insPlcId}','${newDtlVO.dtlId}')" class="link">
                                        <span>删除</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.dtlId != null && newDtlVO.insPlcId == null && (detailFlag == 'false'||isNeedPrice == '1'||isDetail == '0')}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:addPlc('${newDtlVO.dtlId}','${newDtlVO.certNo}','2')" class="link">
                                        <span>添加</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.insPlcId != null}">
                                    &nbsp;&nbsp;
                                    <a href="javascript:showPlc('${newDtlVO.insPlcId}')" class="link">
                                        <span>查看</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">GPS1</div>
                            <div class="field">
                                <span id="newGPS1" name="newGPS1">${newDtlVO.gpsCardNo1}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">GPS2</div>
                            <div class="field">
                                <span id="newGPS2" name="newGPS2">${newDtlVO.gpsCardNo2}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">GPS3</div>
                            <div class="field">
                                <span id="newGPS3" name="newGPS3">${newDtlVO.gpsCardNo3}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">发动机号</div>
                            <div class="field">
                                <span id="newEngineNo" name="newEngineNo">${newDtlVO.engineNo}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">发动机型号</div>
                            <div class="field">
                                <span id="newEngMdl" name="newEngMdl">${newDtlVO.engMdl}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">发票状态</div>
                            <div class="field">
                                <c:if test="${flowFlag != 'false'}">
                                    <span id="newInvoiceSts" name="newInvoiceSts">${newDtlVO.invoiceStsCd}</span>
                                </c:if>
                                &nbsp;&nbsp;
                                <c:if test="${newDtlVO.prdNm != null && detailFlag=='false'}">
                                    <a href="javascript:uploadInvoice(${newDtlVO.dtlId})" class="link">
                                        <span>发票上传</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.prdNm != null && detailFlag!='false'}">
                                    <a href="javascript:showInvoice(${newDtlVO.dtlId})" class="link">
                                        <span>查看</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">厂商</div>
                            <div class="field">
                                <span id="newMfrNm" name="newMfrNm">${newDtlVO.mfrNm}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">挂靠公司</div>
                            <div class="field">
                                <span id="newCompNm" name="newCompNm">${newDtlVO.lnkCompNm}</span>
                                &nbsp;&nbsp;
                                <c:if test="${newDtlVO.prdNm != null && newDtlVO.lnkCompNm == null && detailFlag == 'false'}">
                                    <a href="javascript:modifyLnkComp(${newDtlVO.dtlId})" class="link">
                                        <span>新增</span>
                                    </a>
                                </c:if>
                                <c:if test="${newDtlVO.prdNm != null && newDtlVO.lnkCompNm != null && detailFlag == 'false'}">
                                    <a href="javascript:modifyLnkComp(${newDtlVO.dtlId})" class="link">
                                        <span>更改</span>
                                    </a>
                                    &nbsp;&nbsp;
                                    <a href="javascript:delLnkComp(${newDtlVO.dtlId})" class="link">
                                        <span>移除</span>
                                    </a>
                                </c:if>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">供应商</div>
                            <div class="field">
                                <span id="newSplNm" name="newSplNm">${newDtlVO.splNm}</span>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div tabid="tabB" title="项目资料" id="tabBId" style="display: none;">
                <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
            </div>
            <div tabid="tabC" title="项目信息" id="tabCId" style="display: none;">
                <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
            </div>
            <div tabid="tabD" title="归档信息" id="tabDId" style="display: none;">
                <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
            </div>
        </div>
        <c:if test="${flowFlag == 'false'}">
            <div class="btnsBox" style="text-align: center;">
                <span id="startFlowBtn" class="sq-button sq-button-round">发起流程</span>
            </div>
        </c:if>
        <!-- 流程使用开始 -->
        <input name="preTaskIdsNm" id="preTaskIds" type="text" style="display: none;" value="${preTaskIds}"/>
        <input name="pInstIdNm" id="pInstId" type="text" style="display: none;" value="${pInstId}"/>
        <!-- 流程使用结束-->
        <input name="changeApplyId" id="changeApplyId" type="text" style="display: none;" value="${changeApplyId}">
        <input name="newPrjPrdDtlId" id="newPrjPrdDtlId" type="text" style="display: none;" value="${newPrjPrdDtlId}">
        <input name="newPrjPrdId" id="newPrjPrdId" type="text" style="display: none;" value="${newDtlVO.prjPrdId}">
        <input name="changeTypeCd" id="changeTypeCd" type="text" style="display: none;" value="${changeTypeCd}">
        <input name="paySchId" id="paySchId" type="text" style="display: none;" value="${paySchId}">
        <input name="paySchNo" id="paySchNo" type="text" style="display: none;" value="${prjPrdPaySchMVO.paySchNo}">
        <input name="prjId" id="prjId" type="text" style="display: none;" value="${prjPrdPaySchMVO.prjId}">
        <input name="prjPrdDtlId" id="prjPrdDtlId" type="text" style="display: none;" value="${prjPrdDtlId}">
    </div>
</div>

<script>
    var detailFlag = '${detailFlag}';
    var prjTypCd = '${capPayInfoVO.prjTypCd}';
    var cstId = '${capPayInfoVO.cstId}';
    var wsPaySchId = '${capPayInfoVO.paySchId}';
    var wsPaySchNo = '${capPayInfoVO.paySchNo}';
    var lsCntNo = '${lsCntNo}';
    var proIntId = '${proIntId}';
    var flowFlag = '${flowFlag}';
    var _proIntId = '${proIntId}';//流程实例ID
    var _taskId = '${taskId}';//任务节点ID
    var _taskDefKey = '${taskDefKey}';//任务节点KEY
    var _taskNm = '${taskNm}';//任务节点名称
    var procNm = '${procNm}';//流程名称
    var isDetail = '${isDetail}';//是否信审节点标识
    var arcInfoFlag = '${arcInfoFlag}';//归档信息tab页标识
    var isNeedPrice = '${isNeedPrice}';//核价员核价标识
    var noPassFlag = '${noPassFlag}';//流程不通过标识
    var prjPrdChangeFlag = true;
    var pageInApp = {}; // to 下一级子窗口 接口
    var pageInTab = null;
    var loadedTabs = []
    $(function () {
        //初始化Tab
        initTab();
        $("#formSet1").ligerForm({
            validate: true
        });
        //放款金额
        var payAmt = '${capPayeeInfoVO.payAmt}';
        if (payAmt) {
            $("#oldPayAmt").text(FormatMoney(parseInt(payAmt) / 100));
        }
        //实际放款金额
        var actPayAmt = '${capPayeeInfoVO.actPayAmt}';
        if (actPayAmt) {
            $("#oldActPayAmt").text(FormatMoney(parseInt(actPayAmt) / 100));
        }
        //新资产租赁物价格
        var newGuidePc = '${newDtlVO.prdAmt}';
        if (newGuidePc) {
            $("#newGuidePc").text(FormatMoney(parseInt(newGuidePc) / 100));
        }
        //控制tab显示
        if (flowFlag == 'true') {
            pageInTab.removeTabItem("tabB");
        } else {
            pageInTab.removeTabItem("tabC");
        }
        if (!arcInfoFlag || arcInfoFlag == null || arcInfoFlag == "") {
            pageInTab.removeTabItem("tabD");
        }
        //初始化原资产信息
        initOldData();
    });

    //初始化Tab
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            //minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function (tabid) {
                if (loadedTabs.indexOf(tabid) < 0) {
                    var pInstId = $("#pInstId").val();
                    var preTaskIds = $("#preTaskIds").val();
                    var prjId = $("#prjId").val();
                    var newPrjPrdId = $("#newPrjPrdId").val();
                    var prjPInstId = '${prjPInstId}';
                    var flowParms = "&&pInstId=" + pInstId + "&&preTaskIds=" + preTaskIds;
                    loadedTabs.push(tabid);
                    switch (tabid) {
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjFileInfo/toFileInfoListPage.do?prjId=" + prjId + "&&detailFlag=" + detailFlag + flowParms);
                            break;
                        case "tabC":
                            if (!prjId || !prjPInstId || !newPrjPrdId) {
                                $.ligerDialog.SQalert({content: "抱歉信息不存在！", SQ_type: "warning"});
                                return false;
                            }
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/audit/toAdditionalInfoPage.do?isDetail=" + isDetail + "&projectId=" + prjId + "&processInstanceId="
                                + prjPInstId + '&prjPrdChangeFlag=' + prjPrdChangeFlag + '&prjPrdId=' + newPrjPrdId + '&isNeedPrice=' + isNeedPrice);
                            break;
                        case "tabD":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/archive/arcMgrMain/toMgrInfoView.do?contractNo=" + lsCntNo + "&arcInfoFlag=" + arcInfoFlag);
                            break;
                    }
                }
                SetIframe_height();
            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }

    //当前tab刷新
    function callback() {
        window.location.reload();
    }

    function initOldData() {
        var _prjPrdDtlId = $("#prjPrdDtlId").val();
        var paySchId = $("#paySchId").val();
        if (!_prjPrdDtlId) {
            return;
        }
        var _url = '<%=path%>/changeapply/prjPrdChangeApply/getPrdChangeDetail.do';
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: {
                dtlId: _prjPrdDtlId,
                paySchId: paySchId
            },
            url: _url,
            success: function (msg) {
                if (msg.success == 1) {
                    setOldData(msg.data);//设置数据
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }


    //设置页面数据
    function setOldData(data) {
        $("#oldPrdNm").html(data.prdNm);
        $("#oldPrdNmLink").attr('href', 'javascript:showOldPrjPrdDetail(' + data.prjPrdId + ')');
        $("#oldGuidePc").html(FormatMoney(data.totLsItmAmt / 100));
        $("#oldHp").html(data.hp);
        $("#oldBrand").html(data.brand);
        $("#oldVIN").html(data.vin);
        $("#oldSpSts").html(data.licAudStsCdNm);
        $("#oldCertNo").html(data.certNo);
        $("#oldDySts").html(data.guarStsCdNm);
        $("#oldCommercialPlcStsCd").html(data.commercialPlcStsCdNm);
        $("#oldPlcSts").html(data.plcStsCdNm);
        $("#oldGPS1").html(data.gpsCardNo1);
        $("#oldGPS2").html(data.gpsCardNo2);
        $("#oldGPS3").html(data.gpsCardNo3);
        $("#oldEngineNo").html(data.engineNo);
        $("#oldEngMdl").html(data.engMdl);
        $("#oldInvoiceSts").html(data.invoiceStsCd);
        $("#oldMfrNm").html(data.mfrNm);
        $("#oldCompNm").html(data.lnkCompNm);
        $("#oldSplNm").html(data.splNm);
    }

    /**查看项目产品*/
    function showOldPrjPrdDetail(id) {
        var detailFlag = true;
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_info_detail' + id, '项目产品详细信息', '<%=path%>/project/vehicle/toModifyPage.do?id=' + id + '&prjId=' + prjId + '&detailFlag=' + detailFlag, callback);
    }

    /**查看项目产品*/
    function showPrjPrdDetail(id) {
        var detailFlag = true;
        //启用支付表信息
        var paySchId = $("#paySchId").val();
        var paySchNo = $("#paySchNo").val();
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_info_detail' + id, '项目产品详细信息', '<%=path%>/project/vehicle/toModifyPageHC.do?id=' + id + '&prjId=' + prjId + '&detailFlag=' + detailFlag
            + '&oldDtlId=' + prjPrdDtlId + '&prjPrdChangeFlag=' + prjPrdChangeFlag + '&paySchId=' + paySchId + '&paySchNo=' + paySchNo, callback);
    }

    /**新增项目产品*/
    function addPrjPrd() {
        //启用支付表信息
        var paySchId = $("#paySchId").val();
        var paySchNo = $("#paySchNo").val();
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var prjId = $("#prjId").val();
        $.ligerDialog.open({
            title: '产品详细信息',
            height: 400,
            width: 800,
            url: '<%=path%>/project/vehicle/vehicleList.do?prjId=' + prjId + '&oldDtlId=' + prjPrdDtlId + '&prjPrdChangeFlag=' + prjPrdChangeFlag
                + '&paySchId=' + paySchId + '&paySchNo=' + paySchNo,
            isResize: true,
            callback: callback
        });
    }

    /**新增项目产品-挂车*/
    function addPrjPrdGC() {
        //启用支付表信息
        var paySchId = $("#paySchId").val();
        var paySchNo = $("#paySchNo").val();
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var prjId = $("#prjId").val();
        $.ligerDialog.open({
            title: '产品详细信息',
            height: 400,
            width: 800,
            url: '<%=path%>/vehicle/trailer/trailerList.do?prjId=' + prjId + '&oldDtlId=' + prjPrdDtlId + '&prjPrdChangeFlag=' + prjPrdChangeFlag
                + '&paySchId=' + paySchId + '&paySchNo=' + paySchNo,
            isResize: true,
            callback: callback
        })
    }

    /**修改项目产品*/
    function modifyPrjPrd(id) {
        if (!id) {
            return;
        }
        //启用支付表信息
        var paySchId = $("#paySchId").val();
        var paySchNo = $("#paySchNo").val();
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_info_modify' + id, '修改项目产品信息', '<%=path%>/project/vehicle/toModifyPageHC.do?id=' + id + '&&prjId=' + prjId + '&oldDtlId=' + prjPrdDtlId
            + '&prjPrdChangeFlag=' + prjPrdChangeFlag + '&paySchId=' + paySchId + '&paySchNo=' + paySchNo, callback);
    }

    /**删除所选商品信息*/
    function removePrjPrd(id) {
        if (!id) {
            return;
        }
        //启用支付表信息
        var paySchId = $("#paySchId").val();
        var prjId = $("#prjId").val();
        $.ligerDialog.confirm('合格证上牌抵押等信息会同步删除,是否确认删除?', function (flag) {
            if (flag == false) return;
            //删除产品信息及变更记录
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {
                    prjPrdId: id,
                    paySchId: paySchId,
                    prjId: prjId
                },
                url: '<%=path%>/project/prjprdbscinfo/removeByHC.do',
                success: function (msg) {
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        window.location.reload();
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        })
    }

    /**添加上牌信息*/
    function addSp(dtlId, certNo) {
        if (!dtlId) {
            return;
        }
        if (!certNo && (prjTypCd != "CDDYWUL" && prjTypCd != "ESCJYD" && prjTypCd != "OWNJYD")) {  // 业务类型 车抵贷业务(线下)、二手车交易贷 取消合格证 REQ-3672
            $.ligerDialog.SQalert({content: "请先录入产品合格证信息", SQ_type: "warning"});
            return;
        }
        var prjId = $("#prjId").val();
        var detailFlag = false;
        Add_navTab('tab_prj_prd_veh_info_add' + dtlId, '添加上牌信息', '<%=path%>/project/prjprdlicinfo/toAddPage.do?detailFlag=' + detailFlag + '&&dtlId=' + dtlId
            + '&&prjId=' + prjId + '&&prjPrdChangeFlag=' + prjPrdChangeFlag, callback);
    }

    /**修改上牌信息*/
    function modifySp(dtlId) {
        if (!dtlId) {
            return;
        }
        var prjId = $("#prjId").val();
        var detailFlag = false;
        Add_navTab('tab_prj_prd_veh_info_modify' + dtlId, '修改上牌信息', '<%=path%>/project/prjprdlicinfo/toAddPage.do?detailFlag=' + detailFlag + '&&id=' + dtlId + '&&dtlId=' + dtlId
            + '&&prjId=' + prjId + '&&prjPrdChangeFlag=' + prjPrdChangeFlag, callback);
    }

    /**查看上牌信息*/
    function showSp(_prjPrdDtlId) {
        var prjId = $("#prjId").val();
        var detailFlag = true;
        //调上牌维护页面 传递是否流程标识(isFlow=1)  是的话 页面执行
        Add_navTab('sp_info_add', '查看上牌信息', '<%=path%>/project/prjprdlicinfo/toAddPage.do?isFlow=1&checkSp=${checkSp}&detailFlag=' + detailFlag + '&dtlId=' + _prjPrdDtlId + '&id=' + _prjPrdDtlId
            + '&&prjId=' + prjId + '&&prjPrdChangeFlag=' + prjPrdChangeFlag, callback);
    }

    /**新增抵押信息*/
    function addDy(dtlId) {
        if (!dtlId) {
            return;
        }
        var prjId = $("#prjId").val();
        var detailFlag = false;
        //调抵押维护页面 传递是否流程标识(isFlow=1)  是的话 页面刷新
        Add_navTab('dy_info_add' + dtlId, '添加抵押信息', '<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=1&detailFlag=' + detailFlag + '&dtlId=' + dtlId + '&&prjId=' + prjId, callback);
    }

    /**修改抵押信息*/
    function modifyDy(dtlId) {
        if (!dtlId) {
            return;
        }
        var prjId = $("#prjId").val();
        var detailFlag = false;
        Add_navTab('tab_prj_prd_veh_mtg_modify' + dtlId, '修改抵押信息', '<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=1&detailFlag=' + detailFlag + '&&id=' + dtlId + '&&dtlId=' + dtlId + '&&prjId=' + prjId, callback);
    }

    /**查看抵押信息*/
    function showDy(_prjPrdDtlId) {
        var prjId = $("#prjId").val();
        var detailFlag = true;
        //调抵押维护页面 传递是否流程标识(isFlow=1)  是的话 页面刷新
        Add_navTab('dy_info_add', '查看抵押信息', '<%=path%>/project/prjprdmtg/toAddPage.do?isFlow=${checkDy}&checkDy=${checkDy}&detailFlag=' + detailFlag + '&dtlId=' + _prjPrdDtlId + '&id=' + _prjPrdDtlId
            + '&&prjId=' + prjId, callback);
    }

    /**添加合格证信息*/
    function addPrjPrdVehInfo(dtlId) {
        var detailFlag = false;
        var noLinkButton = true;
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_veh_info_add' + dtlId, '添加合格证', '<%=path%>/project/prjprdvehinfo/toAddPage.do?detailFlag=' + detailFlag + '&&dtlId=' + dtlId + '&&noLinkButton=' + noLinkButton
            + '&&prjId=' + prjId + '&&paySchId=' + wsPaySchId + '&&paySchNo=' + wsPaySchNo + '&&prjPrdChangeFlag=' + prjPrdChangeFlag, callback);
    }

    /**修改合格证信息*/
    function modifyPrjPrdVehInfo(id, dtlId, isGpsNode) {
        var detailFlag = false;
        var noLinkButton = false;
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_veh_info_modify' + id, '修改合格证', '<%=path%>/project/prjprdvehinfo/toAddPage.do?detailFlag=' + detailFlag + '&&id=' + id + '&&dtlId=' + dtlId + '&&noLinkButton=' + noLinkButton
            + '&&prjId=' + prjId + '&&paySchId=' + wsPaySchId + '&&paySchNo=' + wsPaySchNo + '&&prjPrdChangeFlag=' + prjPrdChangeFlag + '&isGpsNode='+isGpsNode, callback);
    }

    /**查看合格证信息*/
    function detailPrjPrdVehInfo(id, dtlId) {
        var detailFlag = true;
        var prjId = $("#prjId").val();
        Add_navTab('tab_prj_prd_veh_info_detail' + id, '合格证详情', '<%=path%>/project/prjprdvehinfo/toDetailPage.do?detailFlag=' + detailFlag + '&&id=' + id + '&&dtlId=' + dtlId
            + '&&prjId=' + prjId + '&&paySchId=' + wsPaySchId + '&&paySchNo=' + wsPaySchNo);
    }

    /**添加挂靠公司*/
    function modifyLnkComp(dtlId) {
        var prjId = $("#prjId").val();
        var _ids = [];
        _ids.push(dtlId);
        var ids = JSON.stringify(_ids);
        $.ligerDialog.open({
            title: '添加产品挂靠公司',
            height: 500,
            width: 850,
            url: '<%=path%>/project/prjprddtl/toChooseLnkCompPage.do?ids=' + ids + '&prjId=' + prjId+ '&prjPrdChangeFlag=' + prjPrdChangeFlag,
            callback: callback
        });
    }

    /**移除挂靠公司*/
    function delLnkComp(dtlId) {
        var _ids = [];
        _ids.push(dtlId);
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) {
                return;
            }
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {ids: JSON.stringify(_ids)},
                url: '<%=path%>/project/prjprddtl/removePrdDtlLnkCompByIds.do',
                success: function (msg) {
                    if (msg.success == 1) {
                        window.location.reload();
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    /**发票上传*/
    function uploadInvoice(id) {
        if (null == id) {
            top.$.ligerDialog.SQalert({content: "未找到产品明细id", SQ_type: "error"});
            return;
        }
        var detailFlag = false;
        Add_navTab('tab_prj_prd_invoice_detail' + id, '发票上传', '<%=path%>/project/prjPrdInvoice/toListPageHC.do?detailFlag=' + detailFlag + '&dtlId=' + id
            + '&paySchId=' + wsPaySchId + '&paySchNo=' + wsPaySchNo, callback);
    }

    /**查看发票*/
    function showInvoice(id) {
        if (null == id) {
            top.$.ligerDialog.SQalert({content: "未找到产品明细id", SQ_type: "error"});
            return;
        }
        var detailFlag = true;
        Add_navTab('tab_prj_prd_invoice_detail' + id, '查看发票', '<%=path%>/project/prjPrdInvoice/toListPageHC.do?detailFlag=' + detailFlag + '&dtlId=' + id
            + '&paySchId=' + wsPaySchId + '&paySchNo=' + wsPaySchNo + '&noPassFlag=' + noPassFlag, callback);
    }

    /**新增保单*/
    function addPlc(dtlId, certNo, insTypCd) {
        if (!certNo && (prjTypCd != "CDDYWUL" && prjTypCd != "ESCJYD" && prjTypCd != "OWNJYD")) {  // 业务类型 车抵贷业务(线下)、二手车交易贷 取消合格证 REQ-3672
            $.ligerDialog.SQalert({content: "请先录入产品合格证信息", SQ_type: "warning"});
            return;
        }
        var prjId = $("#prjId").val();
        var prjPrdDtlId = $("#prjPrdDtlId").val();
        Add_navTab("InsPlcBscInfo_" + dtlId, "新增保单", '<%=path%>/insurance/insPlcBscInfo/toAddPage.do?prjPrdDtlId=' + dtlId + '&cstId=' + cstId
            + '&prjId=' + prjId + '&oldDtlId=' + prjPrdDtlId + '&insTypCd=' + insTypCd, callback);
    }

    /**修改保单*/
    function modifyPlc(_id) {
        if (null == _id) {
            top.$.ligerDialog.SQalert({content: "保单id不可为空", SQ_type: "error"});
            return;
        }
        var prjId = $("#prjId").val();
        Add_navTab('InsPlcBscInfo_2' + _id, "修改保单", '<%=path%>/insurance/insPlcBscInfo/toModifyPage.do?id=' + _id + '&wsPaySchId=' + wsPaySchId+ '&prjId=' + prjId
            + '&prjPrdChangeFlag=' + prjPrdChangeFlag, callback);
    }

    /* 删除 */
    function deletePlc(_id, _prjPrdDtlId) {
        if (!_id) return;
        var _ids = [];
        _ids.push(_id);
        $.ligerDialog.confirm('确定删除吗?', function (flag) {
            if (flag == false) return;
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {
                    ids: JSON.stringify(_ids),
                    prjPrdDtlId: _prjPrdDtlId,
                    prjPrdChangeFlag: prjPrdChangeFlag
                },
                url: '<%=path%>/insurance/insPlcBscInfo/removeByIds.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        window.location.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    /**查看保单*/
    function showPlc(id) {
        if (null == id) {
            top.$.ligerDialog.SQalert({content: "保单id不可为空", SQ_type: "error"});
            return;
        }
        var prjId = $("#prjId").val();
        Add_navTab('InsPlcBscInfo_DTL_' + id, "保单详情", '<%=path%>/insurance/insPlcBscInfo/toDetailPage.do?id=' + id + '&prjId=' + prjId
            + '&paySchNo=' + wsPaySchNo, null);
    }

    /**发起流程*/
    $("#startFlowBtn").click(function (event) {
        $.ligerDialog.confirm("是否确认发起流程？", function (flag) {
            if (flag == false) {
                return;
            }
            var changeApplyId = $('#changeApplyId').val();
            var paySchId = $('#paySchId').val();
            var paySchNo = $('#paySchNo').val();
            var prjId = $('#prjId').val();
            var prjPrdDtlId = $('#prjPrdDtlId').val();
            var newPrjPrdDtlId = $('#newPrjPrdDtlId').val();
            if (!changeApplyId || !newPrjPrdDtlId) {
                UIUtils.alertWarning("请添加新资产信息");
                return false;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {
                    id: changeApplyId,
                    paySchId: paySchId,
                    paySchNo: paySchNo,
                    prjId: prjId,
                    prjPrdDtlId: prjPrdDtlId,
                    newPrjPrdDtlId: newPrjPrdDtlId,
                    changeTypeCd: 2
                },
                url: '<%=path%>/changeApply/flow/changeForHCFlowStart.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        var TAB = top.mainApp.parentTab;
                        var currentTabid = TAB.getSelectedTabItemID();
                        var currFrameElement = top.$("#" + currentTabid).get(0);
                        var callback = currFrameElement.W2W.callback;
                        callback();
                        top.tab.removeTabItem(currentTabid);
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error", SQ_showButtons: true});
                    }
                }
            });
        });
    })

</script>
</body>
</html>